import java.util.*; 
import java.io.*;
import edu.vanderbilt.isis.sm.*; 
import edu.vanderbilt.isis.sm.Pseudostate.Kind; 
import edu.vanderbilt.isis.sm.properties.*; 
import com.martiansoftware.jsap.*;
public class TopLevelAnchorcell { 
	public StateMachine sm = new StateMachine(); 
	public Interpreter sim; 
	public TopLevelAnchorcell() { }
	public static void main(String[] args) throws Exception {
		TopLevelAnchorcell example = new TopLevelAnchorcell();
		FlaggedOption semantics = new FlaggedOption("semantics")
			.setStringParser(JSAP.STRING_PARSER)
	        .setDefault("SF")
	        .setRequired(false)
	        .setShortFlag('s')
	        .setLongFlag("semantics");
		FlaggedOption dataProviderArg = new FlaggedOption("dataProvider")
			.setStringParser(JSAP.STRING_PARSER)
	        .setDefault("CommandLine")
	        .setRequired(false)
	        .setShortFlag('d')
	        .setLongFlag("dataProvider");
		FlaggedOption maxSteps = new FlaggedOption("maxSteps")
			.setStringParser(JSAP.INTEGER_PARSER)
	        .setDefault("10")
	        .setRequired(false)
	        .setShortFlag(JSAP.NO_SHORTFLAG)
	        .setLongFlag("maxSteps");
		FlaggedOption csvFile = new FlaggedOption("csvFilePath")
			.setStringParser(JSAP.STRING_PARSER)
	        .setDefault("")
	        .setRequired(false)
	        .setShortFlag('c')
	        .setLongFlag("csvFile");
		Switch checkOutputSw = new Switch("checkOutput")
	        .setShortFlag(JSAP.NO_SHORTFLAG)
	        .setLongFlag("checkOutput");
		FlaggedOption looperArg = new FlaggedOption("looper")
			.setStringParser(JSAP.STRING_PARSER)
	        .setDefault("Default")
	        .setRequired(false)
	        .setShortFlag('l')
	        .setLongFlag("looper");
		Switch checkPropertiesSw = new Switch("checkProperties").setShortFlag(
				JSAP.NO_SHORTFLAG).setLongFlag("checkProperties");

		JSAP jsap = new JSAP();
		jsap.registerParameter(semantics);
		jsap.registerParameter(dataProviderArg);
		jsap.registerParameter(csvFile);
		jsap.registerParameter(checkOutputSw);
		jsap.registerParameter(maxSteps);
		jsap.registerParameter(looperArg);
		jsap.registerParameter(checkPropertiesSw);
		JSAPResult config = jsap.parse(args);

		IDataProvider dataProvider = new CommandLineDataProvider();
		IDataPrinter dataPrinter = null;
		ILooper looper = new DefaultLooper();
		List<Pattern> patterns = new ArrayList<Pattern>();

		if (config.getString("dataProvider").toUpperCase().equals("CSV")) {
			String fileName = config.getString("csvFilePath");
			boolean checkOutput = config.getBoolean("checkOutput");
			CSVDataProvider csvDP = new CSVDataProvider(fileName, checkOutput);
			dataProvider = csvDP;
			if (checkOutput){
				dataPrinter = csvDP;
			}
		}
		if (config.getString("dataProvider").toUpperCase().equals("SYMBOLIC")) {
			int steps = config.getInt("maxSteps");
			SymbolicDataProvider sDP = new SymbolicDataProvider(steps);
			dataProvider = sDP;
		}

		if (config.getString("looper").toUpperCase().equals("NONDETERMINISTIC")){
			looper = new NondeterministicLooper();
		}

		if (config.getBoolean("checkProperties")) {
			patterns = example.makeProperties(example.r1.Anchorcell3);
		}

		IDataReader dataReader = new AnchorcellReader(example.r1.Anchorcell3, dataProvider, dataPrinter);
		if (config.getString("semantics").toUpperCase().equals("UML")) {
			example.sim = new UMLInterpreter(example.sm, dataReader, looper);
		}
		else if (config.getString("semantics").toUpperCase().equals("RHAPSODY")) {
			example.sim = new RhapsodyInterpreter(example.sm, dataReader, looper);
		}
		else {
			example.sim = new StateflowInterpreter(example.sm, dataReader, looper, patterns);
		}
		example.sim.getLooper().setInterpreter(example.sim);
		example.initializeTransitions();
		example.DoSim();
}
	public void DoSim() { 
		this.sim.initialize(); 
		this.sim.dataAndEventLoop();
	} 
	public List<Pattern> makeProperties(REGION_T.STATE_T s) { 
		ArrayList<Pattern> patterns = new ArrayList<Pattern>(); 
		return patterns; 
	}
	public class REGION_T extends Region { 
	public REGION_T(IRegionParent parent, int order) { 
		super(parent, order); 
	} 
	public Pseudostate p3 = new Pseudostate(this, Kind.INITIAL);
	public class STATE_T extends State {
	public int ISd0 ;
public int formed  = 1 ;
public int ISd2 ;
public int ISd1 ;
public int ISd3 ;
public int KO  = 0 ;
public int delay ;
public int ablated  = 0 ;
public int high  = 3 ;
public int lin3 ;
public int low  = 0 ;
public int low1  = 2 ;
public int med  = 1 ;
public int mut_ac ;
public int mut_lin15 ;
public int off  = 0 ;
public int rf  = 1 ;
	public void setData( int val_0,  int val_1,  int val_2 ) {
		this.delay = val_0;
		this.mut_ac = val_1;
		this.mut_lin15 = val_2;
	}
		public STATE_T( String name, Region parent, boolean isFinal ) { 
			super( name, parent, isFinal ); 
		} 
	public class RegionR17 extends Region { 
	public RegionR17(IRegionParent parent, int order) { 
		super(parent, order); 
	} 
	public Pseudostate p14 = new Pseudostate(this, Kind.INITIAL);
	public class Statelin315 extends State {
			public Statelin315( String name, Region parent, boolean isFinal ) { 
			super( name, parent, isFinal ); 
		} 
	public class RegionR16 extends Region { 
	public RegionR16(IRegionParent parent, int order) { 
		super(parent, order); 
	} 
	public Pseudostate p2 = new Pseudostate(this, Kind.INITIAL);
	public class StateInit116 extends State {
			public StateInit116( String name, Region parent, boolean isFinal ) { 
			super( name, parent, isFinal ); 
		} 
	}
	public StateInit116 Init112 = new StateInit116("Init1", this, false );
	public class StateOff17 extends State {
			public StateOff17( String name, Region parent, boolean isFinal ) { 
			super( name, parent, isFinal ); 
		} 
		public void entryAction() {
		  lin3 = off;
;
		}
	}
	public StateOff17 Off13 = new StateOff17("Off", this, false );
	public class StateMed18 extends State {
			public StateMed18( String name, Region parent, boolean isFinal ) { 
			super( name, parent, isFinal ); 
		} 
		public void entryAction() {
		  lin3 = med;
;
		}
	}
	public StateMed18 Med14 = new StateMed18("Med", this, false );
	public class Transition6 extends Transition { 
		public Transition6( IVertex source, IVertex target, Region parent, List<Event> triggers, int priority ) {
			super( source, target, parent, triggers, priority);
		}
		public boolean guard(IEventHolder holder) {
			return mut_ac == ablated;
		}
		public void action(IEventHolder holder) {
			;
		}
		public void conditionAction(IEventHolder holder) {
			;
		}
	}
	ArrayList<Event> triggers7 = new ArrayList<Event>() { {
		add(new Event(""));
	} };
	Transition6 p5 = new Transition6( Init112, Off13, this, triggers7, 1);
	public class Transition9 extends Transition { 
		public Transition9( IVertex source, IVertex target, Region parent, List<Event> triggers, int priority ) {
			super( source, target, parent, triggers, priority);
		}
		public boolean guard(IEventHolder holder) {
			return mut_ac == formed;
		}
		public void action(IEventHolder holder) {
			;
		}
		public void conditionAction(IEventHolder holder) {
			;
		}
	}
	ArrayList<Event> triggers10 = new ArrayList<Event>() { {
		add(new Event(""));
	} };
	Transition9 p8 = new Transition9( Init112, Med14, this, triggers10, 2);
	public class Transition12 extends Transition { 
		public Transition12( IVertex source, IVertex target, Region parent, List<Event> triggers, int priority ) {
			super( source, target, parent, triggers, priority);
		}
		public void action(IEventHolder holder) {
			;
		}
		public void conditionAction(IEventHolder holder) {
			;
		}
	}
	ArrayList<Event> triggers13 = new ArrayList<Event>() { {
		add(new Event(""));
	} };
	Transition12 p11 = new Transition12( p2, Init112, this, triggers13, 1);
}
public RegionR16 r12 = new RegionR16( this, 0 );
	}
	public Statelin315 lin311 = new Statelin315("lin3", this, false );
	Transition p15 = new Transition(p14, lin311, this, new Event(""));
}
public RegionR17 r11 = new RegionR17( this, 1 );
	public class RegionR20 extends Region { 
	public RegionR20(IRegionParent parent, int order) { 
		super(parent, order); 
	} 
	public Pseudostate p31 = new Pseudostate(this, Kind.INITIAL);
	public class StateISds19 extends State {
			public StateISds19( String name, Region parent, boolean isFinal ) { 
			super( name, parent, isFinal ); 
		} 
	public class RegionR19 extends Region { 
	public RegionR19(IRegionParent parent, int order) { 
		super(parent, order); 
	} 
	public Pseudostate p1 = new Pseudostate(this, Kind.INITIAL);
	public class StateInit220 extends State {
			public StateInit220( String name, Region parent, boolean isFinal ) { 
			super( name, parent, isFinal ); 
		} 
	}
	public StateInit220 Init25 = new StateInit220("Init2", this, false );
	public class StateState221 extends State {
			public StateState221( String name, Region parent, boolean isFinal ) { 
			super( name, parent, isFinal ); 
		} 
	public class RegionR18 extends Region { 
	public RegionR18(IRegionParent parent, int order) { 
		super(parent, order); 
	} 
	public class StateA122 extends State {
			public StateA122( String name, Region parent, boolean isFinal ) { 
			super( name, parent, isFinal ); 
		} 
		public void entryAction() {
		  ISd0 = low;
;ISd1 = low;
;ISd2 = low;
;ISd3 = low;
;
		}
	}
	public StateA122 A17 = new StateA122("A1", this, false );
	public class StateA223 extends State {
			public StateA223( String name, Region parent, boolean isFinal ) { 
			super( name, parent, isFinal ); 
		} 
		public void entryAction() {
		  ISd0 = high;
;ISd1 = med;
;ISd2 = low1;
;ISd3 = low;
;
		}
	}
	public StateA223 A28 = new StateA223("A2", this, false );
}
public RegionR18 r6 = new RegionR18( this, 0 );
	}
	public StateState221 State26 = new StateState221("State2", this, false );
	public class StateB24 extends State {
			public StateB24( String name, Region parent, boolean isFinal ) { 
			super( name, parent, isFinal ); 
		} 
		public void entryAction() {
		  ISd0 = high;
;ISd1 = high;
;ISd2 = high;
;ISd3 = high;
;
		}
	}
	public StateB24 B9 = new StateB24("B", this, false );
	public class StateC25 extends State {
			public StateC25( String name, Region parent, boolean isFinal ) { 
			super( name, parent, isFinal ); 
		} 
		public void entryAction() {
		  ISd0 = high;
;ISd1 = high;
;ISd2 = med;
;ISd3 = med;
;
		}
	}
	public StateC25 C10 = new StateC25("C", this, false );
	public class Transition23 extends Transition { 
		public Transition23( IVertex source, IVertex target, Region parent, List<Event> triggers, int priority ) {
			super( source, target, parent, triggers, priority);
		}
		public void action(IEventHolder holder) {
			;
		}
		public void conditionAction(IEventHolder holder) {
			;
		}
	}
	ArrayList<Event> triggers24 = new ArrayList<Event>() { {
		add(new Event(""));
	} };
	Transition23 p22 = new Transition23( p1, Init25, this, triggers24, 1);
	public class Transition26 extends Transition { 
		public Transition26( IVertex source, IVertex target, Region parent, List<Event> triggers, int priority ) {
			super( source, target, parent, triggers, priority);
		}
		public boolean guard(IEventHolder holder) {
			return mut_lin15 == KO && delay == 16;
		}
		public void action(IEventHolder holder) {
			;
		}
		public void conditionAction(IEventHolder holder) {
			;
		}
	}
	ArrayList<Event> triggers27 = new ArrayList<Event>() { {
		add(new Event(""));
	} };
	Transition26 p25 = new Transition26( State26, B9, this, triggers27, 1);
	public class Transition29 extends Transition { 
		public Transition29( IVertex source, IVertex target, Region parent, List<Event> triggers, int priority ) {
			super( source, target, parent, triggers, priority);
		}
		public boolean guard(IEventHolder holder) {
			return mut_lin15 == rf && delay == 16;
		}
		public void action(IEventHolder holder) {
			;
		}
		public void conditionAction(IEventHolder holder) {
			;
		}
	}
	ArrayList<Event> triggers30 = new ArrayList<Event>() { {
		add(new Event(""));
	} };
	Transition29 p28 = new Transition29( State26, C10, this, triggers30, 2);
	public class Transition17 extends Transition { 
		public Transition17(Region parent, List<Event> triggers, int priority) {
			super(parent, triggers, priority);
		}
		public boolean guard() {
			return lin3 == off;
		}
		public void action( IEventHolder e ) {
			;
		}
		public void conditionAction(IEventHolder e) {
			;
		}
	}
	ArrayList<Event> triggers18 = new ArrayList<Event>() { {
		add(new Event(""));
	} };
	Transition17 p16 = new Transition17(this, triggers18, 1);
	public class Transition20 extends Transition { 
		public Transition20(Region parent, List<Event> triggers, int priority) {
			super(parent, triggers, priority);
		}
		public boolean guard() {
			return lin3 == med;
		}
		public void action( IEventHolder e ) {
			;
		}
		public void conditionAction(IEventHolder e) {
			;
		}
	}
	ArrayList<Event> triggers21 = new ArrayList<Event>() { {
		add(new Event(""));
	} };
	Transition20 p19 = new Transition20(this, triggers21, 2);
}
public RegionR19 r4 = new RegionR19( this, 0 );
	}
	public StateISds19 ISds4 = new StateISds19("ISds", this, false );
	Transition p32 = new Transition(p31, ISds4, this, new Event(""));
}
public RegionR20 r3 = new RegionR20( this, 2 );
	}
	public STATE_T Anchorcell3 = new STATE_T("Anchorcell", this, false );
	Transition p4 = new Transition(p3, Anchorcell3, this, new Event(""));
}
public REGION_T r1 = new REGION_T( sm, 0 );
	public void initializeTransitions() {
		r1.Anchorcell3.r3.ISds4.r4.p16.initialize(r1.Anchorcell3.r3.ISds4.r4.Init25,r1.Anchorcell3.r3.ISds4.r4.State26.r6.A17);
		r1.Anchorcell3.r3.ISds4.r4.p19.initialize(r1.Anchorcell3.r3.ISds4.r4.Init25,r1.Anchorcell3.r3.ISds4.r4.State26.r6.A28);
	}
}
